import { message } from 'antd';
export default {
  namespace: 'ds',

  state: {
    camZmcStates: {}, // 上料控制器状态
    cbjZmcStates: {}, // 裁切机控制器状态
    bigCutterZmcStates: {}, // 前铡刀控制状态
    smallCutterZmcStates: {}, // 后铡刀控制状态
    cameraGroupStates: {}, // 相机组控制器状态
    autoState: false, // 后台自动作业是否停止
    mainAlarmInfo: '', // 铡刀总控制器的报警信息框
    mainAlarmInfoVisible: false, // 底层报警提示框是否显示
    operaProcedureStart: true, // 机械手放板方向
    camZmcIOStates: [
      {
        key: '1',
        IO: '1',
        start: true,
        annotation: 'New York No. 1 Lake Park',
      },
    ],
    cbjZmcIOStates: [],
    bigCutterZmcIOInfo: [],
    smallCutterZmcIOInfo: [],
    camZmcOPStates:[],
    cbjZmcOPStates:[],
    bigCutterZmcOPStates:[],
    smallCutterZmcOPStates:[],
  },

  // 和后台交互
  effects: {
    *handleDeviceStatesMessage({ payload }, { call, put }) {
      const { msg } = payload;
      yield put({
        type: 'updateDeviceStates',
        payload: msg,
      });
    },
  },

  // 状态更新
  reducers: {
    updateDeviceStates(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },

    closeMainAlarmInfoModal(state, action) {
      return {
        ...state,
        mainAlarmInfoVisible: false,
        mainAlarmInfo: '',
      };
    },
  },
};
